package com.zhuanyongjin.server;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.zhuanyongjin.dao.categoryDao;
import com.zhuanyongjin.dao.member_yongjinDao;
import com.zhuanyongjin.dao.impl.categoryDaoImpl;
import com.zhuanyongjin.dao.impl.member_yongjinDaoImpl;

public class categoryServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		//获取被点击图片的id
		String name=request.getParameter("name");
		int page=Integer.parseInt(request.getParameter("page"));
		int rows=Integer.parseInt(request.getParameter("rows"));
		categoryDao categorys = new categoryDaoImpl();
		//返回点击图片对应页面的内容
		List list = categorys.querycategory(rows,page);
		JSONArray json=JSONArray.fromObject(list);
		if(list.size()>0){
			out.print(json);
			System.out.println("success!");
		}
		else
		{
			out.println("error");
		}
		out.flush();
		out.close();
	}
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
